package com.gxc.service;

import com.github.pagehelper.PageInfo;
import com.gxc.dao.jpa.ItemSkuRepository;
import com.gxc.dao.mybatis.ItemSkuMapper;
import com.gxc.entity.ItemSku;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * ItemSkuService.
 *
 * @author 宫新程
 * @since 2019/2/13 19:28
 */
@Service
public class ItemSkuService {

  @Resource private ItemSkuMapper itemSkuMapper;
  @Resource private ItemSkuRepository itemSkuRepository;

  /** Mybatis 分页查询. */
  public PageInfo<ItemSku> myBatisFindAll(Integer pageNum, Integer pageSize) {
    List<ItemSku> list = itemSkuMapper.findAll(pageNum, pageSize);
    return new PageInfo<>(list);
  }

  /** jpa分页查询. */
  public Page<ItemSku> jpaFindAll(Integer pageNum, Integer pageSize) {
    Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
    return itemSkuRepository.findAll(pageable);
  }
}
